package com.hyt.it.ogt.kq.service.gov.feign.file;

import com.github.tobato.fastdfs.domain.FileInfo;
import com.hyt.core.exception.NestedBusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;


/**
 * <p>
 *  文件服务Feign客户端熔断器
 * </p>
 *
 * @author Chengxh
 * @since 2021-08-14
 */
@Component
@Slf4j
public class GovFileClientHystrix implements GovFileClient {

    @Override
    public String uploadFile(@RequestPart(value = "file") MultipartFile file) throws NestedBusinessException {
        log.error("#上传文件失败，进入熔断");
        throw new NestedBusinessException("上传文件失败");
    }

    @Override
    public String uploadFile(@RequestBody byte[] bytes, @RequestParam String format) throws NestedBusinessException {
        log.error("#上传byte[]文件失败，进入熔断");
        throw new NestedBusinessException("上传byte[]文件失败");
    }

    @Override
    public String uploadFile(@RequestParam String content, @RequestParam String fileExtension) throws NestedBusinessException {
        log.error("#上传字符文件失败，进入熔断");
        throw new NestedBusinessException("上传字符文件失败");
    }

    @Override
    public String uploadFileByUrl(@RequestParam String url, @RequestParam long fileSize, @RequestParam String fileExtension) {
        log.error("#上传字符文件失败，进入熔断");
        throw new NestedBusinessException("上传字符文件失败");
    }

    @Override
    public String uploadImageAndCrtThumbImage(@RequestPart(value = "file") MultipartFile file) throws NestedBusinessException {
        log.error("#上传图片并生成缩略图失败，进入熔断");
        throw new NestedBusinessException("上传图片并生成缩略图失败");
    }

    @Override
    public String getThumbImagePath(@RequestParam String filePath) throws NestedBusinessException {
        log.error("#根据图片路径获取缩略图路径失败，进入熔断");
        throw new NestedBusinessException("根据图片路径获取缩略图路径失败");
    }

    @Override
    public FileInfo queryFileInfo(@RequestParam String filePath) throws NestedBusinessException {
        log.error("#获取文件信息失败，进入熔断");
        throw new NestedBusinessException("获取文件信息失败");
    }

    @Override
    public byte[] downFile(@RequestParam String filePath) throws NestedBusinessException {
        log.error("#下载文件失败，进入熔断");
        throw new NestedBusinessException("下载文件失败");
    }
    @Override
    public InputStream downFileByStream(String filePath) {
        log.error("#下载流文件失败，进入熔断");
        throw new NestedBusinessException("下载流文件失败");
    }
    @Override
    public void deleteFile(@RequestParam String filePath) throws NestedBusinessException {
        log.error("#删除文件失败，进入熔断");
        throw new NestedBusinessException("删除文件失败");
    }

}
